﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UserInterface.Views
{
    using Helpers;
    using Events;

    /// <summary>
    /// Interaction logic for AllUnitList.xaml
    /// </summary>
    public partial class ShowInfoList : UserControl
    {
        public ShowInfoList(IEnumerable<UnitInfomation> source)
        {
            InitializeComponent();
            DataGrid.ItemsSource = source;
        }

        public ShowInfoList(IEnumerable<SettlementInfomation> source)
        {
            InitializeComponent();
            DataGrid.ItemsSource = source;
        }

        public ShowInfoList(IEnumerable<GameLibrary.Unit.Template> templates)
        {
            InitializeComponent();
            DataGrid.ItemsSource = templates;
        }

        public event EventHandler<SelectedItemEventArgs> Select;
        private void OnSelect()
        {
            if (Select != null)
                Select(this, new SelectedItemEventArgs(this.DataGrid.CurrentItem));
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.DataGrid.Resources != null
                && this.DataGrid.CurrentItem != null)
                OnSelect();
        }
    }
}
